from lib.api.Student import sm
from lib.webui.StudentOp import sop
from hytest import GSTORE, INFO, STEP, CHECK_POINT


class StudentWeb1:
    name = "学生登录1 - tc005081"

    def teststeps(self):
        STEP(1, "添加学生")

        ret = sm.add_student(username='dxs', realname='大学生', gradeid=1,
                             classid=GSTORE['七一班-id'], phonenumber="123123")
        retAdd = ret.json()

        CHECK_POINT("添加学生检查", retAdd['retcode'] == 0)

        self.student_id = retAdd['id']

        STEP(2, "学生登录")

        sop.studentLogin(username='dxs', password='888888')
        infos = sop.getStuHomePageInfo()

        INFO(infos)

        expected = ['大学生', '白月学院00002', '0', '0']

        CHECK_POINT("学生首页信息检查", infos == expected)

    def teardown(self):
        sm.delete_student(studentid=self.student_id)
